package com.huike.web.controller.businessClueTrack;


import com.huike.business.domain.TbBusinessRecord;
import com.huike.business.service.BusinessRecord;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.dto.TbClueTrackDTO;
import com.huike.clues.domain.vo.ClueTrackVo;
import com.huike.clues.service.ITbClueTrackService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.sun.deploy.net.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import java.net.URI;
import java.util.List;
import java.util.Map;

@RestController
public class TrackController extends BaseController {
    @Autowired
    private BusinessRecord businessRecord;

    @Autowired
    private ITbClueTrackService tbClueTrackService;

    @RequestMapping("/business/record/list")
    public AjaxResult findList(@RequestParam(value = "businessId") Long businessId) {
        return AjaxResult.success(businessRecord.findList(businessId));
    }

    @PostMapping("/business/record")
    public AjaxResult insertBusinessRecord(@RequestBody TbBusinessRecord tbBusinessRecord) {
        businessRecord.insertBusinessRecord(tbBusinessRecord);
        return AjaxResult.success();
    }


    @PostMapping("/clues/record")
    public AjaxResult record(@RequestBody ClueTrackVo clueTrackVo) {
        tbClueTrackService.addRecord(clueTrackVo);
        return AjaxResult.success();
    }

    @GetMapping("/clues/record/list")
    public TableDataInfo list(@RequestParam("clueId") Long clueId) {
        startPage();
        List<TbClueTrackDTO> tbClueTrackDTOS = tbClueTrackService.selectList(clueId);
        return getDataTable(tbClueTrackDTOS);
    }

    @PutMapping("/clues/clue/false/{clueId}")
    public AjaxResult clueFalse(@PathVariable long clueId, @RequestBody Map<String, Object> map) {
        tbClueTrackService.addFalseReason(clueId, map);
        return AjaxResult.success();
    }

}